package il.ac.technion.wiki.api;

/**
 * Defines an interface for converting content from different content types
 * into the wiki's expected content format.
 *
 */
public interface IContentImporter {
	public static class ContentException extends Exception {
		private static final long serialVersionUID = 8940768998041308175L;
		public ContentException() { super(); }
		public ContentException(String message, Throwable cause) { super(message, cause); }
		public ContentException(String message) { super(message); }
		public ContentException(Throwable cause) { super(cause); }
	}
	
	/**
	 * Returns the types of content the importer handles.
	 * @return	A string array representing all the types of content the importer handles.
	 * 			This will usually specify the appropriate mime-types.
	 */
	String[] handledContentTypes();
	
	/**
	 * Converts a piece of content from the importer's handled content type into
	 * the format expected by the wiki engine.s
	 * @param content	The content to convert. This is a byte array to support
	 * 					formats that may contain non-readable characters.
	 * @return			The content, after conversion.
	 * @throws ContentException	If the conversion fails for any reason. Probably this
	 * 							is because the specified content was of the wrong
	 * 							type for this importer.
	 */
	String process(byte[] content) throws ContentException;
}
